<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
<div class="container-fluid" id="viewruleContent">
  <div class="row">
    <h5 class="over-title margin-bottom-15">View Measure</h5>
  </div>
  <!--//row-->
  <div class="row y-scrollable" style="max-height: 350px;">
    <div class="col-sm-6 col-xs-12">
      <div id="viewruleDefinition" class="viewrule-content">
        <div class="row">
          <label class="col-xs-4">
            Measure Name:
          </label>
          <div class="col-xs-8 " style="color: #fff">
            {{ruleData.name}}
          </div>
        </div>
        <div class="row">
          <label class="col-xs-4">
            Measure Description:
          </label>
          <div class="col-xs-8 " style="color: #fff">
            {{ruleData.description}}
          </div>
        </div>
        <div class="row">
          <label class="col-xs-4">
            Measure Type:
          </label>
          <div class="col-xs-8 " style="color: #fff">
            {{ruleData.type}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.dqType">
          <label class="col-xs-4">
            Dq Type:
          </label>
          <div class="col-xs-8 " style="color: #fff">
            {{ruleData.dqType}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.type=='accuracy'">
          <label class="col-xs-4">
            Source:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{sourceTable}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.type=='profiling'">
          <label class="col-xs-4">
            DataSource:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{sourceTable}}
          </div>
        </div>
        <div class="row" *ngIf="sourcesize">
          <label class="col-xs-4">
            Source Partition Size:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{sourcesize}}
          </div>
        </div>
        <div class="row" *ngIf="sourcezone">
          <label class="col-xs-4">
            Source Time Zone:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{sourcezone}}
          </div>
        </div>
        <div class="row" *ngIf="sourcewhere">
          <label class="col-xs-4">
            Source Where:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{sourcewhere}}
          </div>
        </div>
        <div class="row" *ngIf="sourcepath">
          <label class="col-xs-4">
            Source Path:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{sourcepath}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.type=='accuracy'">
          <label class="col-xs-4">
            Target:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{targetTable}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.type=='accuracy' && targetsize">
          <label class="col-xs-4">
            Target Partition Size:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{targetsize}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.type=='accuracy' && targetzone">
          <label class="col-xs-4">
            Target Time Zone:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{targetzone}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.type=='accuracy' && targetwhere">
          <label class="col-xs-4">
            Target Where:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{targetwhere}}
          </div>
        </div>
        <div class="row" *ngIf="ruleData.type=='accuracy' && targetpath">
          <label class="col-xs-4">
            Target Path:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{targetpath}}
          </div>
        </div>
        <div class="row">
          <label class="col-xs-4">
            Owner:
          </label>
          <div class="col-xs-8" style="color: #fff">
            {{ruleData.owner}}
          </div>
        </div>
      </div>
    </div>
  </div>
  <!--//row-->
  <br/>
  <div *ngIf="ruleData['measure.type']!=='external'">
    <h5 class="row">Mapping rules</h5>
    <div *ngIf="ruleData.type=='accuracy'" class="">
      <p *ngFor="let index of currentrule">{{index.rule}}</p>
      <div>
        <p>
          <label style="color:#B2C831">Accuracy Calculation Formula as Below:</label>
        </p>
        <div class="col-md-12 col-lg-12 col-sm-12" style="color:#fff;font-size:16px;display: flex;align-items: center">
          <div class="" style="text-align:right;display:block;float:left;width:20%;">
            Accuracy Rate(%) =
          </div>
          <div class="" style="text-align:center;display:block;float:left;margin:0 10px 0 10px">
            <div class="formula-text-up" style="border-bottom:1px solid;">
              Total Count of Matched records between <span class="badge">{{sourceLength}}</span> <span
              style="color:green;">{{targetTable}}</span> and <span class="badge">{{sourceLength}}</span> <span
              style="color:green;">{{sourceTable}}</span> fields
            </div>
            <div class="">
              Total Count of records in <span style="color:green;font-weight:bold;">{{targetDB}}&nbsp;&nbsp;{{targetTable}}</span>
            </div>
          </div>
          <div class="" style="text-align:left;display:block;float:left;width:10%;">
            x 100%
          </div>
        </div>
      </div>
    </div>
    <div *ngIf="ruleData.type=='profiling'" class="">
      <div *ngFor="let index of ruleDes;">
        {{index.name}}&nbsp;:&nbsp;{{index.infos}}
      </div>
    </div>
    <h5 class="row">Rules</h5>
    <div *ngIf="ruleData['evaluate.rule']">
      <div class="row">
        <div class="col-md-6 col-lg-6 col-sm-6">
          <label class="form-check-label">
            Show rules only:
            <input class="form-check-input" type="checkbox" [checked]="!showFullRules" (change)="showFullRules = !showFullRules">
          </label>
        </div>
        <div class="col-md-6 col-lg-6 col-sm-6">
          <div class="btn-group btn-group-sm navbar-right" role="group" aria-label="Format">
            <button type="button" class="btn btn-flat btn-primary" [ngClass]="{'active': format == Format.json}" (click)="format=Format.json">JSON</button>
            <button type="button" class="btn btn-flat btn-primary" [ngClass]="{'active': format == Format.yaml}" (click)="format=Format.yaml">YAML</button>
          </div>
        </div>
      </div>
      <div class="row">
        <pre class="code-viewport">{{ getRawContent() }}</pre>
      </div>
    </div>
  </div>
</div>
